package com.hdoit.ares.logical.tp.zzb.service.impl;

import java.util.Map;

import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import com.hdoit.ares.logical.tp.zzb.model.AccidentCallback;
import com.hdoit.ares.logical.tp.zzb.service.IAccidentCallbackService;
import com.tennetcn.common.dao.base.impl.SuperService;
import com.tennetcn.common.enums.ModelStatus;
import com.tennetcn.common.utils.CommonUtils;
import com.tennetcn.common.utils.DateUtils;
import com.xiaoleilu.hutool.json.JSONUtil;
/**
 * @author      caochengmeng
 * @email       
 * @createtime  2017年12月10日 23:06:03
 * @comment
 */
@Component
public class AccidentCallbackServiceImpl extends SuperService<AccidentCallback> implements IAccidentCallbackService{

	//意外险通用解析
	@Override
	public AccidentCallback resolveAccidentCallback(String accident, String orderSn){
		if (StringUtils.isEmpty(accident)) {
			return null;
		}
		AccidentCallback accidentCallback = new AccidentCallback();
		Map<String, Object> accidentCallbackMap = JSONUtil.parseObj(accident);

		accidentCallback.setId(CommonUtils.getKeyId());
		accidentCallback.setModelStatus(ModelStatus.add);
		accidentCallback.setOrderId(orderSn);
		accidentCallback.setOrderInfo(MapUtils.getString(accidentCallbackMap, "orderInfo"));
		accidentCallback.setInsuredInfo(MapUtils.getString(accidentCallbackMap, "insuredInfo"));
		try {
			accidentCallback.setAppntInfo(MapUtils.getString(accidentCallbackMap, "appntInfo"));
		} catch (Exception e) {
			e.getStackTrace();
		}
		accidentCallback.setPolicyInfo(MapUtils.getString(accidentCallbackMap, "policyInfo"));
		accidentCallback.setCreateDate(DateUtils.getCurrent());
		return accidentCallback;
	}
}